<template>
	<view class="com-container">
		<c-layout>
			<!-- 头部 -->

			<c-navigation-bar @backEvent="backEvent" @W="inputEvent" :is-search="true" @searchEvent="searchEvent"
				searchBgcolor="#F6F7FB" :input="searchInput"></c-navigation-bar>

			<!-- <goodsInfo :goodsInfo="goodsList[1]"></goodsInfo> -->
			<view class="shenhe-container">
				<view class="tab-container">
					<u-tabs-swiper ref="uTabs" :current="current" :list="navList" swiperWidth="750" height="80"
						:activeColor="'#2934d0'" :fontSize="29" :bold="false" :barWidth="101" :barHeight="4"
						@change="tabsChange" :is-scroll="false"></u-tabs-swiper>
				</view>
				<!-- 活动 -->
				<view class="" style="margin: 10rpx 40rpx 0rpx 40rpx">
					<u-notice-bar type="" mode="horizontal" color="rgba(41, 52, 208, 1)" border-radius="8"
						bgColor="rgba(41, 52, 208, 0.1)" :list="list" :more-icon="true" @getMore="goActice()"></u-notice-bar>
				</view>
				<swiper style="height: 100%" :current="swiperCurrent" @transition="transition" :disable-touch="true"
					@animationfinish="animationfinish"  @change="swiperChange">

					<!-- 全部-->
					<swiper-item class="swiper-item">
						<scroll-view class="aaaaa" scroll-y :style="{'height': allList.length === 0 ? '380rpx' : (allList.length + 1) * 380 - 350 + 'rpx'}"  style="width: 100%;" @scrolltolower="onreachBottom">

							<!-- 订单列表 -->
							<view class="swiper-div" v-if="allList.length>0">
								<goodsCard :isServer="false" :isStatus="true" :goodsList="allList" @pay="pay" :cancelType="0"
									:unShipped="true" @change="goCancleOrder(arguments)" @deleteOrder="deleteOrder" @drawback="drawback">
								</goodsCard>
								<!-- <view ref="loadMoreView"></view> -->
							</view>

							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view>
						</scroll-view>
							<!-- 推荐店铺 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendShop') }}
								</view>
							<!-- 	<scroll-view :scroll-x="true" style="white-space: nowrap; height: 254rpx">
									<view class="" style="width: 500rpx;"> -->
										<view class="shopBox">
											<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
												<view class="shop-image">
													<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
														mode="aspectFill"></image>
												</view>
												<view class="shop-name">{{item.shopName}}</view>
											</view>									
										</view>
									<!-- </view>
								</scroll-view> -->
							</view>
							<!-- 推荐商品 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
					</swiper-item>
					<!-- 未付款 -->
					<swiper-item class="swiper-item">
						<scroll-view scroll-y :style="{'height': unipaidList.length === 0 ? '380rpx' : (unipaidList.length + 1) * 380 - 350 + 'rpx'}" style="width: 100%;" @scrolltolower="onreachBottom">


							<view class="swiper-div" v-if="unipaidList.length>0">
								<goodsCard :goodsList="unipaidList" :btnText="btnTextList[0]" @pay="pay" :cancelType="0"
									@change="goCancleOrder(arguments)"></goodsCard>
								<!-- <view ref="loadMoreView"></view> -->
							</view>

							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view>
							</scroll-view>
							<!-- 推荐店铺 -->
							<view class="goods-box">
								<view class="title">
									{{ $t('product.recommendShop') }}
								</view>
								<view class="shopBox">

									<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
										<view class="shop-image">
											<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
												mode="aspectFill"></image>
										</view>
										<view class="shop-name">{{item.shopName}}</view>
									</view>

								</view>
							</view>
							<!-- 推荐商品 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
						
					</swiper-item>
					<!-- 未发货 -->
					<swiper-item class="swiper-item">
						<scroll-view scroll-y :style="{'height': unShippedList.length === 0 ? '380rpx' : (unShippedList.length + 1) * 380 - 350 + 'rpx'}" style="width: 100%;" @scrolltolower="onreachBottom">


							<view class="swiper-div" v-if="unShippedList.length>0">
								<goodsCard :goodsList="unShippedList"  @change="goRefund" @pay="pay" :unShipped="true"
									@drawback="drawback"></goodsCard>

								<view ref="loadMoreView"></view>
							</view>
							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view>
							</scroll-view>
							<!-- 推荐店铺 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendShop') }}
								</view>
								<view class=" shopBox">

									<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
										<view class="shop-image">
											<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
												mode="aspectFill"></image>
										</view>
										<view class="shop-name">{{item.shopName}}</view>
									</view>

								</view>
							</view>
							<!-- 推荐商品 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
						
					</swiper-item>
					<!-- 已发货 -->
					<swiper-item class="swiper-item">
						<scroll-view scroll-y :style="{'height': shippedList.length === 0 ? '380rpx' : (shippedList.length + 1) * 380 - 350 + 'rpx'}" style="width: 100%;"  @scrolltolower="onreachBottom">


							<view class="swiper-div" v-if="shippedList.length>0">
								<goodsCard :goodsList="shippedList"  @getGoodsInfo="getGoodsInfo()" :btnText="btnTextList[1]"
									@change="goRefund" @pay="pay"></goodsCard>

								<view ref="loadMoreView"></view>
							</view>
							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view>
							</scroll-view>
							<!-- 推荐店铺 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendShop') }}
								</view>
								<view class=" shopBox">

									<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
										<view class="shop-image">
											<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
												mode="aspectFill"></image>
										</view>
										<view class="shop-name">{{item.shopName}}</view>
									</view>

								</view>
							</view>
							<!-- 推荐商品 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
						
					</swiper-item>
					<!-- 已完成 -->
					<swiper-item class="swiper-item">
						<scroll-view scroll-y :style="{'height': completedList.length === 0 ? '380rpx' : (completedList.length + 1) * 380 - 350 + 'rpx'}" style="width: 100%;" @scrolltolower="onreachBottom">

  
							<view class="swiper-div" v-if="completedList.length>0">
								<goodsCard :goodsList="completedList" @change="returnGoods" @getGoodsInfo="returnGoods()" @pay="pay"
									:completed="true" ></goodsCard>
								<!-- 加载中 -->
								<view ref="loadMoreView"></view>
							</view>
							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view>
							</scroll-view>
							<!-- 推荐店铺 -->
							<scroll-view scroll-x  style="width: 100%;" >
								<view class="goods-box" >
									<view class="title">
										{{ $t('product.recommendShop') }}
									</view>
									<view class=" shopBox">

										<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
											<view class="shop-image">
												<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
													mode="aspectFill"></image>
											</view>
											<view class="shop-name">{{item.shopName}}</view>
										</view>

									</view>
								</view>
							</scroll-view>
							<!-- 推荐商品 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
						
					</swiper-item>
					<!-- <swiper-item class="swiper-item">
						<scroll-view scroll-y style="height: 100%; width: 100%" @scrolltolower="onreachBottom"> -->

							<!-- 待评价 -->
					<!-- 		<view class="swiper-div" v-if="evaluateList.length>0">
								<goodsCard :btnText="btnTextList[3]" :goodsList="evaluateList" @pay="pay" :isComment="true"
									:completed="true"></goodsCard>
								<!-- 加载中 -->
							<!-- 	<view ref="loadMoreView"></view>
							</view>
							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view> -->
							<!-- </scroll-view> -->
							<!-- 推荐店铺 -->
						<!-- 	<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendShop') }}
								</view>
								<view class="reviews-main  shopBox">

									<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
										<view class="shop-image">
											<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
												mode="aspectFill"></image>
										</view>
										<view class="shop-name">{{item.shopName}}</view>
									</view>

								</view>
							</view> -->
							<!-- 推荐商品 -->
						<!-- 	<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
						
					</swiper-item> -->
					<!-- 售后 -->
					<swiper-item class="swiper-item">
						<scroll-view scroll-y :style="{'height': serverList.length === 0 ? '380rpx' : (serverList.length + 1) * 380 - 350 + 'rpx'}" style="width: 100%;" @scrolltolower="onreachBottom">

							<view class="swiper-div" v-if="serverList.length>0">
								
									<goodsCard :isServer="true" :isStatus="true" :goodsList="serverList" @pay="pay" :cancelType="0"
										:unShipped="true" @change="goCancleOrder(arguments)" @deleteOrder="deleteOrder" @drawback="drawback">
									</goodsCard>
								<!-- 加载中 -->
								<view ref="loadMoreView"></view>
							</view>
							<view class="swiper-div" v-else style="margin: 50rpx auto; text-align: center;">
								<image style="width: 200rpx;height: 200rpx;" src="../../static/images/no-data.png" mode=""></image>
								<view class="">
									{{ $t('order.noOrder') }}
								</view>
							</view>
							</scroll-view>
							<!-- 推荐店铺 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendShop') }}
								</view>
								<view class="shopBox">

									<view class="shop-list" v-for="item in shopList" :key="item.id" @click="goShop(item)">
										<view class="shop-image">
											<image style="width: 112rpx;height: 112rpx;" :src="$u.file.getMedieUrl(item.shopAvatarUrl)"
												mode="aspectFill"></image>
										</view>
										<view class="shop-name">{{item.shopName}}</view>
									</view>

								</view>
							</view>
							<!-- 推荐商品 -->
							<view class="goods-box" >
								<view class="title">
									{{ $t('product.recommendCommodities') }}
								</view>
								<view class="reviews-main">
									<productCard :details="{ ...item, h: 280 }" v-for="item in goodList" :key="item.id"
										@click="goProductDetail(item)"></productCard>
								</view>
							</view>
						
					</swiper-item>
				</swiper>
			</view>

			<uni-load-more status="more" :show="isShowLoadMore" :styles="styles" @loading="onLoadMore" :showText="false"
				color="#2934D0"></uni-load-more>
		</c-layout>
		
		<!-- 确认删除 -->
		<u-modal v-model="deleteShow" :show-title='false' @confirm="confirm" :confirm-text="$t('system.affirm')"
			:cancel-text="$t('system.cancel')" show-cancel-button :content="$t('order.deleteOrder') " ref="uModal"
			:async-close="true"></u-modal>
	</view>
</template>
<script>
	import goodsCard from '@/components/goodsCard/goodsCard.vue'
	import { log } from 'mathjs';
	export default {
		data() {
			return {
				control:true,
				scrollHeight:380,
				shopList: [],
				noMore: false,
				goodList: [],
				list: [123213212312321312321321],
				contentText: '加载中',
				styles: {
					// 自定义组件样式
					background: '#f4f4f4',
					color: '#888'
				},
				pageNum: 1, // 当前页数
				isShowLoadMore: false, // 是否显示上拉加载更多组件
				allList: [], //售后
				unipaidList: [], //待付款
				unShippedList: [], //未发货
				shippedList: [], //待收货
				completedList: [], // 确认收货
				evaluateList: [], //待评价  确认收货
				serverList: [], //售后
				unpaid: 'unpaid',
				shipped: 'shipped',
				btnTextList: [this.$t('orderDetails.payment'), this.$t('orderDetails.logistics'), this.$t(
					'orderDetails.Completed'), this.$t('orderDetails.evaluation')],
				appBaseUrl: process.uniEnv.COSHost,
				//输入框占位
				searchInput: {
					value: '',
					disabled: false,
					type: 'text',
					// maxlength: 10,
					navPlaceholder: 'search',
					placeholder: this.$t('orderDetails.searchPlace'),
				},  
				//路由传参
				naviData: {},
				//tabs
				navList: [{
						name: this.$t('orderDetails.allOrder')
					},
					{
						name: this.$t('orderDetails.Unpaid')
					},
					{
						name: this.$t('orderDetails.UnShipped')
					},
					{
						name: this.$t('orderDetails.Shipped')
					},
					{
						name: this.$t('orderDetails.Completed')
					},
					{
						name: this.$t('orderDetails.Service')
					}
				],
				toLower: false, //是否为触底加载更多
				current: 0, // tabs组件的current值，表示当前活动的tab选项
				swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
				pageNumS: 1, //搜索
				goodsList: [],
				searching: false,
		
				// 删除订单弹窗
				deleteShow: false,
				orderId: '',
			};
		},
		onLoad() {
			// this.reset()
			// 获取活动
			this.$u
				.post('/app/seckillActivity/oneActivity', {
					activityLocaltion: 1
				})
				.then((res) => {
					this.isactivity = res.data ? true : false;
					this.list = [res.data ? res.data.activityName : this.$t('home.catError')];
				});

			//获取推荐商品
			this.$u.get(`/app/shopGoodsInfo/productRecommended`).then((res) => {
				this.goodList = res.data;
			});

			//获取推荐店铺
			this.$u
				.post(`/app/shop/list`, {
					pageSize: 8,
					pageNum: 1
				})
				.then((res) => {
					this.shopList = res.data.records;
				});
		},
		onShow() {
			// console.log(77777);
			this.allList = [];
			this.unipaidList = [];
			this.unShippedList = [];
			this.shippedList = [];
			this.completedList = [];
			this.evaluateList = [];
			this.serverList = [];
			this.pageNum = 1
			this.pageNumS = 1
			let index = this.swiperCurrent;
			this.control=true
			switch (index) {
				case 0:
					this.getAllList();
					break;
				case 1:
					this.getunipaidList();
					break;
				case 2:
					this.getUnshippedList();
					break;
				case 3:
					this.getShippedList();
					break;
				case 4:
					this.getCompletedList();
					break;
				case 5:
					// this.getEvaluateList();
					this.getServerList();
					break;
				// case 6:
				// 	this.getServerList();
				// 	break;
				default:
					break;
			}
		},
		computed:{
			// scrollHeight2(){
			// 	return this.scrollHeight + 'rpx'
			// }
		},
		methods: {
			//申请退款
			drawback(item) {

			},
			// 删除订单
			deleteOrder(item) {
				this.orderId = item.orderInfo.id
				this.deleteShow = true
			},

			confirm() {
				let data = {
					orderId: this.orderId
				}

				this.$u.post(`/app/shopOrderInfo/delete`, data).then((r) => {
					if (r.code == 200) {
						this.$u.toast(this.$t('product.deleteSuccess'));
						this.control=true
						this.reset()
						this.deleteShow = false
					}
				}).catch(err => {
					console.log(err)
					this.deleteShow = false
				})

			},
		
			reset() {
				this.allList = [];
				this.unipaidList = [];
				this.unShippedList = [];
				this.shippedList = [];
				this.completedList = [];
				this.evaluateList = [];
				this.serverList = [];
				this.pageNum = 1
				this.pageNumS = 1
				let index = this.swiperCurrent;
				
				switch (index) {
					case 0:
						this.getAllList();
						break;
					case 1:
						this.getunipaidList();
						break;
					case 2:
						this.getUnshippedList();
						break;
					case 3:
						this.getShippedList();
						break;
					case 4:
						this.getCompletedList();
						break;
					case 5:
						// this.getEvaluateList();
						this.getServerList();
						break;
					// case 6:
					// 	this.getServerList();
					// 	break;
					default:
						break;
				}

			},

			// 前往推荐商品详情
			goShop(item) {
				uni.navigateTo({
					url: '/pages/shop/index?shopId=' + item.id
				});
			},
			// 前往推荐商品详情
			goProductDetail(item) {
				uni.navigateTo({
					url: '/pages/productDetails/productDetails?productId=' + item.id
				});
			},
			// 前往活动详情
			goActice() {
				if (this.isactivity) {
					uni.navigateTo({
						url: '/pages/seckill/seckill'
					});
				} else {
					this.$u.toast(this.$t('home.catError'));
				}
			},
			//返回主页
			backEvent() {
				uni.switchTab({
					url: '/pages/user/user',
					animationType: 'slide-in-bottom	',
					animationDuration: 200
				});
			},
			//底部加载更多
			onreachBottom() {
				// console.log(3333333333333333);
				if(this.control){return}
				if (this.searching) {
					this.searchEvent(this.contentText, 2);
				} else {
					let index = this.swiperCurrent;

					switch (index) {
						case 0:
							this.getAllList();
							break;
						case 1:
							this.getunipaidList();
							break;
						case 2:
							this.getUnshippedList();
							break;
						case 3:
							this.getShippedList();
							break;
						case 4:
							this.getCompletedList();
							break;
						case 5:
							// this.getEvaluateList();
							this.getServerList();
							break;
						// case 6:
						// 	this.getServerList();
						// 	break;
						default:
							break;
					}
				}
				
			},

			//请求数据
			// payStatus支付状态,0:未支付，1：已支付，2：支付失败
			// orderStatus订单状态,0:未发货,1:已发货，2：确认收货，3：退货中，4：退货完成
			// console.log(this.unipaidList);
			// console.log(this.shippedList);
			// console.log(this.completedList);
			// console.log(11111,this.evaluateList);

			//全部
			getAllList() {
				uni.showLoading();
				// console.log(this.pageNum);
				this.isShowLoadMore = true;				
				let data = {
					size: 10,
					current: this.pageNum
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records; // 假设接口返回数据格式为 { data: [...] }
						if (nextDataList.length > 0) {
							this.allList = this.allList.concat(nextDataList);
							this.pageNum++;
							uni.hideLoading();
							this.control=false
						} else {
							// uni.showToast({
							// 	title: 'no more',
							// 	icon: 'none'
							// });
							// this.noMore = true;
						}
					} else {
						uni.showToast({
							title: 'err',
							icon: 'none'
						});
					}
				});
				this.isShowLoadMore = false;
			},
			//未付款
			getunipaidList() {
				// console.log(this.pageNum);

				this.isShowLoadMore = true;
				let data = {
					size: 10,
					current: this.pageNum,
					orderId: null,
					status: 0					
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records; // 假设接口返回数据格式为 { data: [...] }
						if (nextDataList.length > 0) {
							this.unipaidList = this.unipaidList.concat(nextDataList);
							this.pageNum++;
							this.control=false
						} else {
							// uni.showToast({
							// 	title: 'no more',
							// 	icon: 'none'
							// });
							// this.noMore = true
						}
					} else {
						uni.showToast({
							title: 'err',
							icon: 'none'
						});
					}
				});
				this.isShowLoadMore = false;
			},
			//未发货
			getUnshippedList() {
				console.log('未发货');
				this.isShowLoadMore = true;
				let data = {
					size: 20,
					current: this.pageNum,
					// payStatus: 1,
					status: 1
					// orderStatus: 0
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records; // 假设接口返回数据格式为 { data: [...] }
						if (nextDataList.length > 0) {
							this.unShippedList = this.unShippedList.concat(nextDataList);
							this.pageNum++;
							this.control=false
						} else {
							// uni.showToast({
							// 	title: 'no more',
							// 	icon: 'none'
							// });
							// this.noMore = true
						}
					} else {
						uni.showToast({
							title: 'err',
							icon: 'none'
						});
					}
				});
				this.isShowLoadMore = false;
			},
			//已发货
			getShippedList() {
				this.isShowLoadMore = true;
				let data = {
					size: 20,
					current: this.pageNum,
					// payStatus: 1,
					status: 2
					// orderStatus: 1
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records; // 假设接口返回数据格式为 { data: [...] }
						if (nextDataList.length > 0) {
							this.shippedList = this.shippedList.concat(nextDataList);
							this.pageNum++;
							this.control=false
						} else {
							// uni.showToast({
							// 	title: 'no more',
							// 	icon: 'none'
							// });
							// this.noMore = true
						}
					} else {
						uni.showToast({
							title: 'err',
							icon: 'none'
						});
					}
				});
				this.isShowLoadMore = false;
			},
			getCompletedList() {
				this.isShowLoadMore = true;
				let data = {
					size: 20,
					current: this.pageNum,
					status: 3
					
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records; // 假设接口返回数据格式为 { data: [...] }
						if (nextDataList.length > 0) {
							this.completedList = this.completedList.concat(nextDataList);
							this.pageNum++;
							this.control=false
						} else {
							// uni.showToast({
							// 	title: 'no more',
							// 	icon: 'none'
							// });
							// this.noMore = true
						}
					} else {
						uni.showToast({
							title: 'err',
							icon: 'none'
						});
					}
				});
				this.isShowLoadMore = false;
			},
			// 待评价
			getEvaluateList() {
				this.isShowLoadMore = true;
				let data = {
					size: 10,
					current: this.pageNum,				
					status: 3,
					comment: 0
					
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records; // 假设接口返回数据格式为 { data: [...] }
						if (nextDataList.length > 0) {
							this.evaluateList = this.evaluateList.concat(nextDataList);
							this.pageNum++;
							this.control=false
						} else {
							uni.showToast({
								title: 'no more',
								icon: 'none'
							});
							this.noMore = true
						}
					} else {
						// uni.showToast({
						// 	title: 'err',
						// 	icon: 'none'
						// });
					}
				});
				this.isShowLoadMore = false;
			},

			//售后
			getServerList() {
				this.isShowLoadMore = true;
				let data = {
					size: 10,
					current: this.pageNum,
					status: 4,
				};
				this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					if (res.code == 200) {
						const nextDataList = res.data.records;
						if (nextDataList.length > 0) {
							this.serverList = this.serverList.concat(nextDataList);

							this.pageNum++;
							this.control=false
						} else {
							// uni.showToast({
							// 	title: 'no more',
							// 	icon: 'none'
							// });
							// this.noMore = true
						}
					} else {
						uni.showToast({
							title: 'err',
							icon: 'none'
						});
					}
				});
				this.isShowLoadMore = false;
			},

			//申请退货
			returnGoods(item) {
				console.log(222, item);
				this.$u.route('/pages/orderDetails/orderDetails', {
					type: 4,
					orderId: item.orderInfo.id,
					moneys: item.orderInfo.moneys,
					num: item.orderInfo.totalNum,
					totalPostage: item.totalPostage
				});
				this.$u.vuex('vuex_shoping_cart', item.orderSkus);
				this.$u.vuex('vuex_shoping_cartList', item);
			},
			//申请退款
			goRefund(item) {
				// console.log(item.orderInfo);
				// this.$u.route('/pages/orderDetails/orderDetails', {
				// 	type: this.swiperCurrent,
				// 	orderId: item.orderInfo.id,
				// 	moneys: item.orderInfo.moneys,
				// 	num: item.orderInfo.totalNum,
				// 	totalPostage: item.totalPostage
				// });
				// this.$u.vuex('vuex_shoping_cart', item.orderSkus);
				// this.$u.vuex('vuex_shoping_cartList', item);
				// console.log(item);
				// uni.navigateTo({
				// 	url: `/pages/order/forRefund?type=0&data=` + encodeURIComponent(JSON.stringify(item[0])),
				// 	animationType: 'slide-in-right',
				// 	animationDuration: 300
				// });
			},
			//取消订单
			goCancleOrder(item) {
				console.log(4545);
				// console.log("取消訂單",item[0]);
				let orderData = JSON.stringify(item[0]);
				let newStr = orderData.replace(/%/g, '%25');

				uni.navigateTo({
					url: `/pages/order/cancleOrder?type=1&data=` + encodeURIComponent(newStr),
					animationType: 'slide-in-right',
					animationDuration: 300
				});
			},

			// 点击商品跳转
			pay(item) {
				console.log(999, item);
				// console.log(1111, item);
				// 支付状态,0:未支付，1：已支付，2：支付失败
				// 订单状态,0:未发货,1:已发货，2：确认收货，3：退货中，4：退货完成
				//售后  0未处理1不同意2同意

				this.$u.vuex('vuex_shoping_cartList', item);
				
				console.log(item.orderSkus)
				this.$u.vuex('vuex_shoping_cartList', item);
				this.$u.vuex('vuex_shoping_cart', item.orderSkus);
				this.$u.route('/pages/orderDetails/orderDetails', {
					// type: this.swiperCurrent,
					orderId: item.orderInfo.id,
					moneys: item.orderInfo.moneys,
					num: item.orderInfo.totalNum,
					totalPostage: item.orderInfo.totalPostage,
					createTime: item.orderInfo.createTime,
					goodStatus: item.orderInfo.goodStatus,
					countTime: item.orderInfo.countTime
				});
				// if (this.swiperCurrent !== 5) {
				// 	let obj = {};

				// 	obj.consigUser = item.orderInfo.consigUser;
				// 	// obj.addressId = this.defaulAddress.id;

				// 	obj.address = item.orderInfo.address;
				// 	obj.city = item.orderInfo.city;
				// 	obj.country = item.orderInfo.country;
				// 	obj.countryName = item.orderInfo.countryName;
				// 	obj.mobile = item.orderInfo.mobile;
				// 	obj.landmark = item.orderInfo.landmark;
				// 	obj.postalCode = item.orderInfo.postalCode;
				// 	this.$u.vuex('vuex_address_info', obj);
				// }

				// if (this.swiperCurrent == 5) {
				// 	//已取消
				// 	if (Number(item.isDelete)) {
				// 		return;
				// 	} else {
				// 		//未取消
				// 		if (item.status == 0) {
				// 			if ((item.processUser == 1 && item.sign == 1) || (item.processUser == 1 && item.sign == 0)) {
				// 				// 未处理 &审核中
				// 				uni.navigateTo({
				// 					url: '/pages/order/refundProgress', //进度条
				// 					animationType: 'slide-in-right',
				// 					animationDuration: 300
				// 				});
				// 			} else if (item.processUser == 2) {
				// 				//退货中
				// 				uni.navigateTo({
				// 					url: '/pages/order/fillTrackingNumber?type=1', //展示运单号++
				// 					animationType: 'slide-in-right',
				// 					animationDuration: 300
				// 				});
				// 			}
				// 		} else if (item.status == 1) {
				// 			// 审核不通过
				// 			if (item.processUser !== 2) {
				// 				uni.navigateTo({
				// 					url: '/pages/order/forRefund?type=1', //重新申请
				// 					animationType: 'slide-in-right',
				// 					animationDuration: 300
				// 				});
				// 			} else {
				// 				//退货不成功
				// 				uni.navigateTo({
				// 					url: '/pages/order/refundProgress', //进度条 退货原因
				// 					animationType: 'slide-in-right',
				// 					animationDuration: 300
				// 				});
				// 			}
				// 		} else if (item.status == 2) {
				// 			// 退货成功
				// 			if (item.processUser == 2) {
				// 				uni.navigateTo({
				// 					url: '/pages/order/refundProgress', //进度条
				// 					animationType: 'slide-in-right',
				// 					animationDuration: 300
				// 				});
				// 			} else {
				// 				//审核通过
				// 				uni.navigateTo({
				// 					url: '/pages/order/fillTrackingNumber?type=0', //输入运单号++
				// 					animationType: 'slide-in-right',
				// 					animationDuration: 300
				// 				});
				// 			}
				// 		}
				// 	}

				// 	this.$u.vuex('vuex_shoping_cartList', item);
				// } else if (this.swiperCurrent == 5) {
				// 	// if (!item.comment) {
				// 	// 	//评价
				// 	// 	uni.navigateTo({
				// 	// 		url: '/pages/order/evaluateDetail',
				// 	// 		animationType: 'slide-in-right',
				// 	// 		animationDuration: 300
				// 	// 	});
				// 	// }
				// } else {
				// 	// uni.navigateTo({
				// 	// 	url: '/pages/orderDetails/orderDetails?id=' + ('6' || item.orderInfo.id) + '&type=' + this.swiperCurrent,
				// 	// 	animationType: 'slide-in-right',
				// 	// 	animationDuration: 300
				// 	// });
				// 	// console.log(item.orderSkus)
				// 	// this.$u.vuex('vuex_shoping_cartList', item);
				// 	// this.$u.vuex('vuex_shoping_cart', item.orderSkus);
				// 	// this.$u.route('/pages/orderDetails/orderDetails', {
				// 	// 	// type: this.swiperCurrent,
				// 	// 	orderId: item.orderInfo.id,
				// 	// 	moneys: item.orderInfo.moneys,
				// 	// 	num: item.orderInfo.totalNum,
				// 	// 	totalPostage: item.orderInfo.totalPostage,
				// 	// 	createTime: item.orderInfo.createTime,
				// 	// 	goodStatus: item.orderInfo.goodStatus,
				// 	// 	countTime: item.orderInfo.countTime
				// 	// });
				// }
			},

			// tabs通知swiper切换
			tabsChange(index) {		
				this.searchInput.value = '';
				this.searching = false;
				this.toLower = false;
				this.swiperCurrent = index;			
				this.pageNum = 1;
				this.pageNumS = 1;
				this.control=true
				this.reset() 
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition(e) {				
				let dx = e.detail.dx;
				this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish(e) {
				// console.log(11111);			
				let current = e.detail.current;
				this.$refs.uTabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
				// this.reset()
			},
			swiperChange(e){
				// console.log(33333);	
				let current = e.detail.current;
				// this.reset()
				
			},

			//输入内容发生变化触发此事件
			inputEvent(val) {
				if (val) {
					this.typeBox = 'fuzzyList';
				} else {
					this.typeBox = 'searchList';
				}
			},
			//搜索
			searchEvent(val, type) {
				if (type !== 2) {
					this.pageNumS = 1;
				}
				this.searching = true;
				this.contentText = val;
				let data = {};
				let index = this.swiperCurrent;
				if (this.pageNumS == 1) {
					this.allList = [];
					this.unipaidList = [];
					this.unShippedList = [];
					this.shippedList = [];
					this.completedList = [];
					this.evaluateList = [];
					this.serverList = [];
				}
				switch (index) {
					case 0:
						data = {
							size: 10,
							current: this.pageNumS,
							condition: this.contentText
						};
						this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
							if (res.code == 200) {
								const nextDataList = res.data.records;
								if (nextDataList.length > 0) {
									this.allList = this.allList.concat(nextDataList);
									this.pageNumS++;
								} else {
									uni.showToast({
										title: 'no more',
										icon: 'none'
									});
								}
							} else {
								uni.showToast({
									title: 'err',
									icon: 'none'
								});
							}
						});
						break;
					case 1:
						data = {
							size: 10,
							current: this.pageNumS,
							condition: this.contentText,
							status: 0
						};
						this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
							if (res.code == 200) {
								const nextDataList = res.data.records;
								if (nextDataList.length > 0) {
									this.unipaidList = this.unipaidList.concat(nextDataList);

									this.pageNumS++;
								} else {
									uni.showToast({
										title: 'no more',
										icon: 'none'
									});
								}
							} else {
								uni.showToast({
									title: 'err',
									icon: 'none'
								});
							}
						});
						break;
					case 2:
						data = {
							size: 10,
							current: this.pageNumS,
							condition: this.contentText,
							status: 1
						};
						this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
							if (res.code == 200) {
								const nextDataList = res.data.records;
								if (nextDataList.length > 0) {
									this.unShippedList = this.unShippedList.concat(nextDataList);

									this.pageNumS++;
								} else {
									uni.showToast({
										title: 'no more',
										icon: 'none'
									});
								}
							} else {
								uni.showToast({
									title: 'err',
									icon: 'none'
								});
							}
						});
						break;
					case 3:
						data = {
							size: 10,
							current: this.pageNumS,
							condition: this.contentText,
							status: 2
						};
						this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
							if (res.code == 200) {
								const nextDataList = res.data.records;
								if (nextDataList.length > 0) {
									this.shippedList = this.shippedList.concat(nextDataList);

									this.pageNumS++;
								} else {
									uni.showToast({
										title: 'no more',
										icon: 'none'
									});
								}
							} else {
								uni.showToast({
									title: 'err',
									icon: 'none'
								});
							}
						});
						break;
					case 4:
						data = {
							size: 10,
							current: this.pageNumS,
							condition: this.contentText,
							status: 3
						};
						this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
							if (res.code == 200) {
								const nextDataList = res.data.records;
								if (nextDataList.length > 0) {
									this.completedList = this.completedList.concat(nextDataList);

									this.pageNumS++;
								} else {
									uni.showToast({
										title: 'no more',
										icon: 'none'
									});
								}
							} else {
								uni.showToast({
									title: 'err',
									icon: 'none'
								});
							}
						});
						break;
					// case 5:
					// 	data = {
					// 		size: 10,
					// 		current: this.pageNumS,
					// 		condition: this.contentText,
					// 		payStatus: 1,
					// 		orderStatus: 2
					// 	};
					// 	this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
					// 		if (res.code == 200) {
					// 			const nextDataList = res.data.records;
					// 			if (nextDataList.length > 0) {
					// 				this.evaluateList = this.evaluateList.concat(nextDataList);

					// 				this.pageNumS++;
					// 			} else {
					// 				uni.showToast({
					// 					title: 'no more',
					// 					icon: 'none'
					// 				});
					// 			}
					// 		} else {
					// 			uni.showToast({
					// 				title: 'err',
					// 				icon: 'none'
					// 			});
					// 		}
					// 	});
					// 	break;
					case 5:
						//售后
						// console.log(1111);
						data = {
							size: 10,
							current: this.pageNumS,
							condition: this.contentText,
							status: 4,
						};
						this.$u.post('/app/shopOrderInfo/list', data).then((res) => {
							if (res.code == 200) {
								const nextDataList = res.data.records;
								if (nextDataList.length > 0) {
									this.serverList = this.serverList.concat(nextDataList);

									this.pageNumS++;
								} else {
									uni.showToast({
										title: 'no more',
										icon: 'none'
									});
								}
							} else {
								uni.showToast({
									title: 'err',
									icon: 'none'
								});
							}
						});
						break;
					default:
						break;
				}

				this.typeBox = 'productList';
				// this.searchInput.value = '';清空输入框
			}
		}
	};
</script>
<style lang="scss" scoped>
.shenhe-container {
	font-family: PingFang SC;
	display: flex;
	flex-direction: column;
	height: 86vh;
	margin-left: 20rpx;
		.tab-container {
			height: 80rpx;
			margin-left: 20rpx;
		}

		.swiper {
			height: 100vh;
		}
	}

	.swiper {
		height: 100vh;
	}

	// 推荐列表
	.goods-box {
		margin-top: 30rpx;
		
		.title {
			display: flex;
			justify-content: space-between;
			color: #000;
			font-size: 36rpx;
			font-weight: bold;
			line-height: 48rpx;
			margin: 10rpx 40rpx 32rpx;
		}

		.reviews-main {
			margin: 40rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.product-card-container {
				width: 45%;
			}
		}
	}

	.shop-list {
		margin-bottom:20rpx ;
		.shop-image {
			width: 112rpx;
			height: 112rpx;
			border-radius: 50%;
			overflow: hidden;
			margin-right: 20rpx;
		}

		.shop-name {
			color: #171717;
			font-family: PingFang SC;
			text-align: center;
			font-size: 22rpx;
			width: 112rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
	}

	/deep/.shopBox {
		flex-wrap: wrap;
		justify-content: start !important;
		overflow: auto;
		margin: 40rpx;
		display: flex;
		justify-content: start;
	}

	/deep/ .uni-image>img {
		width: 112rpx;
		height: 112rpx;
	}
	.swiper-item{
		overflow: auto;
	}
</style>